package com.jani.platform.test.controller;

import com.jani.platform.core.ret.Result;
import com.jani.platform.core.vo.HoldValue;
import com.jani.platform.test.model.User;
import com.jani.platform.test.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * springMVC测试
 */
@RestController
public class HelloController {

    @Autowired
    private UserServiceImpl userService;

    @RequestMapping("hello")
    public String hello(@RequestBody HoldValue<String> name){
        return "hello ,"+name.getValue();
    }

    @RequestMapping("selectById")
    public ResponseEntity<User> selectById(@RequestBody HoldValue<String> id){
        return ResponseEntity.ok(userService.selectById(id.getValue()));
    }

    @RequestMapping("selectAll")
    public Result select(){
        return Result.Success(userService.selectAll());
    }
}
